<?php

namespace app\index\controller;

use app\BaseApiController;

class Index extends BaseApiController
{
    /**
     * 前台首页
     */
    public function index()
    {
        return $this->success([
            'module' => 'index',
            'time' => date('Y-m-d H:i:s'),
            'welcome' => '欢迎访问前台'
        ], '前台首页');
    }
    
    /**
     * 获取网站信息
     */
    public function info()
    {
        return $this->success([
            'site_name' => 'ThinkPHP 8 多模块示例',
            'version' => \think\facade\App::version(),
            'time' => date('Y-m-d H:i:s')
        ], '获取网站信息成功');
    }
    
    /**
     * 联系表单提交
     */
    public function contact()
    {
        $params = $this->getParams([
            'name|姓名' => 'require|max:50',
            'email|邮箱' => 'require|email',
            'message|留言' => 'require|max:500'
        ]);
        
        // 模拟处理联系表单
        $result = [
            'name' => $params['name'],
            'email' => $params['email'],
            'message' => $params['message'],
            'submit_time' => date('Y-m-d H:i:s')
        ];
        
        return $this->success($result, '提交成功，我们会尽快回复您');
    }
}
